<%@ page contentType="text/html; charset=utf-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>后台管理 - 爱购物-商城</title>
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/static/css/style.css"/>
</head>
<body>
<c:import url="/static/page/manager-header-nav.jsp">
    <c:param name="nav" value="product"/>
</c:import>
<div id="position" class="wrap">
    您现在的位置：<a href="${pageContext.request.contextPath}/index">爱购物-商城</a> &gt; 管理后台 &gt; 商品管理
</div>
<div id="main" class="wrap clearfix">
    <c:import url="/static/page/manage-left-nav.jsp"/>
    <div class="main">
        <h2>商品管理</h2>
        <div class="manage">
            <table class="list">
                <tr>
                    <th>ID</th>
                    <th>分类</th>
                    <th>商品名称</th>
                    <th>价格</th>
                    <th>操作</th>
                </tr>
                <c:forEach var="p" items="${page.rows}">
                    <tr>
                        <td class="first w2 c">${p.id }</td>
                        <td class="w1 c">${p.category.name}</td>
                        <td class="thumb"><img src="${pageContext.request.contextPath}${p.fileName }" width="80" height="80"/>
                            <a href="#" target="_blank">${p.name }</a></td>
                        <td class="w1 r">${p.price}元</td>
                        <td class="w1 c">
                            <a href="${pageContext.request.contextPath}/manage/product/update?id=${p.id }">修改</a>
                            <a href="javascript:deleteProduct(${p.id })">删除</a></td>
                    </tr>
                </c:forEach>
            </table>
        </div>
        <c:import url="/static/page/manage-pager.jsp">
            <c:param name="page" value="product"/>
            <c:param name="pageNo" value="${page.pageNo}"/>
            <c:param name="pages" value="${page.pages}"/>
            <c:param name="total" value="${page.total}"/>
        </c:import>
    </div>
</div>
<c:import url="/static/page/footer.jsp"/>
<script>
    function deleteProduct(id) {
        if (confirm("确定要删除该商品么？")) {
            location.href = "${pageContext.request.contextPath}/manage/product/delete?id=" + id;
        }
    }
</script>
</body>
</html>

